import { medicalRecordPage } from "@/api/MedicalExamination";
import { BasicColumn, BasicTable, FormSchema, useTable } from "@/components/Table";
import Toolbar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";

const medicalRecordStatus = () => {
	const { t } = useTranslation();

	const searchFormSchema: FormSchema[] = [
		{
			label: t("kevin_ui.from_date"),
			field: "fromDate",
			component: "DatePicker"
		},
		{
			label: t("kevin_ui.to_date"),
			field: "toDate",
			component: "DatePicker"
		},
		{
			label: "Ward",
			field: "ward",
			component: "Input"
		},
		{
			label: "Status",
			field: "status",
			component: "Select"
		},
		{
			label: "Discharge Date",
			field: "dischargeDate",
			component: "DatePicker"
		}
	];
	const columns: BasicColumn[] = [
		{
			title: t("kevin_ui.record_status"),
			dataIndex: "status"
		},
		{
			title: t("kevin_ui.department"),
			dataIndex: "deptName"
		},
		{
			title: t("flandre_ui.admission_number"),
			dataIndex: "admissionNumber"
		},
		{
			title: t("patientBasic.patient_id"),
			dataIndex: "patientId",
			render: (_, record) => (record.patients ? record.patients.patientId : "")
		},
		{
			title: t("patientBasic.full_name"),
			dataIndex: "fullName",
			render: (_, record) => (record.patients ? record.patients.fullName : "")
		},
		{
			title: t("patientBasic.birthday"),
			dataIndex: "birthday",
			render: (_, record) => (record.patients ? record.patients.birthday : "")
		},
		{
			title: t("patientBasic.gender"),
			dataIndex: "gender",
			render: (_, record) => (record.patients ? record.patients.gender : "")
		},
		{
			title: t("patientBasic.pat_type"),
			dataIndex: "patientType",
			render: (_, record) => (record.patients ? record.patients.patientType : "")
		},
		{
			title: t("patientBasic.patient_code"),
			dataIndex: "patCardno",
			render: (_, record) => (record.patients ? record.patients.patCardno : "")
		},
		{
			title: t("kevin_ui.admission_diagnosis"),
			dataIndex: "admissionDiagnosis",
			render: (_, record) => (record.adDiagnosis ? record.adDiagnosis.rxDiagnosis : "")
		},
		{
			title: t("kevin_ui.discharge_diagnosis"),
			dataIndex: "dischargeDiagnosis",
			render: (_, record) => (record.disDiagnosis ? record.disDiagnosis.rxDiagnosis : "")
		},
		{
			title: t("kevin_ui.doctor"),
			dataIndex: "atdDoctorName"
		}
	];
	const [registerTable] = useTable({
		api: medicalRecordPage,
		columns: columns,
		formConfig: {
			labelWidth: 120,
			schemas: searchFormSchema,
			showActionButtonGroup: true,
			baseColProps: { span: 8 }
		},
		useSearchForm: true
	});

	return (
		<div className="medicalRecordStatus page">
			<div className="page-content">
				<BasicTable register={registerTable}></BasicTable>
			</div>
			<Toolbar btnList={["print"]} />
		</div>
	);
};
export default medicalRecordStatus;
